<template>
	<view class="page" v-if="isRender">
		<view class="page__bd">
			<view class="u-p-50 bg-white">
				<view class="user u-flex ">
					<u-image width="100rpx" shape="circle" height="100rpx" :src="info.user.avatar"></u-image>
					<view class="info u-col-center u-m-l-30">
						<view>{{info.user.nickname}}</view>
						<view class="time">{{info.createtime_text}}</view>
					</view>
				</view>
				<view class="content u-p-t-40 u-p-b-40">
					<view class="images u-m-b-30">
						<u-image @click="previewImage(i)" v-for="(img,i) in info.images_array" :src="img" width="180"
							height="180"></u-image>
					</view>
					<u-parse :html="info.content"></u-parse>
				</view>
				<view class="address u-flex u-p-t-20 u-p-b-20" @click="openLocation()">
					<u-icon class="icon" name="map-fill"></u-icon>
					<view class="value u-line-1">{{info.address}}</view>
				</view>
			</view>
			<view class="bg-white u-p-50 u-m-t-30" v-if="info.solvetime > 0">
				<u-section title="处理回复:" :right="false"></u-section>
				<view class="u-m-t-30">
					<u-parse :html="info.solve_reply"></u-parse>
				</view>
			</view>
		</view>
	</view>
</template>
<script>
	export default {
		data() {
			return {
				info: null,
				isRender: false
			}
		},
		onLoad(options) {
			let that = this;
			this.$u.api.getReportDetail({
				id: options.id
			}).then(res => {
				that.info = res.data;
				that.isRender = true;
			});
		},
		methods: {
			previewImage: function(i) {
				uni.previewImage({
					urls: this.info.images_array,
					current: i
				});
			},
			openLocation: function() {
				uni.openLocation({
					latitude: parseFloat(this.info.lat),
					longitude: parseFloat(this.info.lng),
					name: this.info.labels,
					address: this.info.address,
					success: function() {
						console.log('openLocation success');
					},
					fail: function(error) {
						uni.showToast({
							title: error,
							duration: 2000

						});
					}
				});
			}

		},
		onShareAppMessage() {
			return {
				title: this.info.content,
				imageUrl: this.info.images_array[0]
			}
		},
		onShareTimeline() {
			return {
				title: this.info.content,
				imageUrl: this.info.images_array[0]
			}
		}
	}
</script>

<style>
	page {
		background-color: #f4f4f4;
	}

	.bg-white {
		background-color: #ffffff;
	}

	.user .time {
		font-size: 24rpx;
		color: #999999;
	}

	.address .value {
		color: #999;
		margin-left: 4rpx;
	}

	.images {
		display: flex;
		align-items: center;
		flex-wrap: wrap;
	}

	.images .u-image {
		margin-right: 10rpx;
		margin-bottom: 10rpx;
	}

	.images .u-image:nth-child(3n) {
		margin-right: 0;
	}
</style>
